import { apiHttp } from '/@/utils/axios';
import type { commonResponse } from './common'

export interface companyBaseModel {
  corpId: string;
  corpCode: string;
  corpName: string;
  regType?: string;
  legalPerson?: string;
  corpOldName?: string;
  regionName?: string;
  compRegAddr?: string;
  enterCorp?: string;
  compRegDate?: number;
  lastUpdate?: number;
  creationTime?: number;
  quals?: string[];
}

export interface corpCountModel {
  "aptCertCount"?: number;
  "safetyCount"?: number;
  "staffCount"?: number;
  "limitCount"?: number;
  "buildingCount"?: number;
  "projectCount"?: number;
  "historyCount"?: number;

}


export const getCompListApi = params => {
  return apiHttp.post({ url: '/corp/companyList', params });
}

export const getCompanyBaseApi = (corpId:string) => {
  return apiHttp.post<companyBaseModel>({ url: '/corp/companyBase', params: { corpId } });
}


export const getCountApi = (corpId:string) => {
  return apiHttp.post<corpCountModel>({ url: '/corp/corpCount', params: { corpId } });
}

export interface qualItem {
  aptType: string;
  certNo: string;
  aptName: string;
  releaseDate: string;
  validEdate: string;
  approveOrganName: string;
}

export interface Item {
  certAuditId: string;
  certApproveDate: number;
  certRemark:string;
}

export const getCompanyQualApi = (t, params) => {
  enum Api {
    qual = '/corp/qualification',
    safe = '/corp/safety'
  }
  return apiHttp.post<commonResponse>({ url:  Api[t], params }, { isTransformRequestResult: false });
}

export const getCompanySafeApi = params => {
  return apiHttp.post<commonResponse>({ url: '/corp/safety', params }, { isTransformRequestResult: false });
}



export const getCompanyStaffApi = (t,params) => {
  enum Api {
    reg = '/corp/personRegister',
    prof = '/corp/personTitle',
    safe = '/corp/personSafety',
    post = '/corp/personPost',
    tech = '/corp/personTechnology',
    spec = '/corp/personSpecial'
  }
  return apiHttp.post<commonResponse>({ url: Api[t], params }, { isTransformRequestResult: false });
}

export const getCompanyCreditApi = (params) => {
  return apiHttp.post<commonResponse>({ url:'/corp/creditRecord', params }, { isTransformRequestResult: false });
}

export const getCompanyLimitApi = (params) => {
  return apiHttp.post<commonResponse>({ url:'/corp/behaviorLimit', params }, { isTransformRequestResult: false });
}

export const getExpireLimitApi = (params) => {
  return apiHttp.post<commonResponse>({ url:'/corp/expireLimit', params }, { isTransformRequestResult: false });
}


export interface creditLevel {
  creditGrade: string;
  typeName: string;
  typeNum: string	;
}

export enum creditLevelEnum {
  APP_XYPJ_XYDJ_0001 = 1,
  APP_XYPJ_XYDJ_0002 = 2,
  APP_XYPJ_XYDJ_0003 = 3,
  APP_XYPJ_XYDJ_0004 = 4,
  APP_XYPJ_XYDJ_0005 = 5
}

export const colorArr = [
    '#46BBFE',
    '#F0B462',
    '#6A8BFC',
    '#6CDECE',
    '#FE8CA6',
]

export const getCompanyCreditLevelApi = objectId => {
  return apiHttp.post<creditLevel[]>({ url:'/corp/creditGrade', params: {objectId} });
}

export const getQualChangeApi = params => {
  return apiHttp.post({ url:'/corp/qualChange', params });
}

export const getIndexCodeApi = indexCode => {   //类型查询
  if(typeof indexCode === "string"){
    return apiHttp.post({ url:'/data/paramQuery', params : { indexCode } });
  }else {
    return apiHttp.post({ url:'/data/paramQuery', params :indexCode });
  }
}


export const getBuildingProjectApi = params => {
  return apiHttp.post({ url:'/corp/buildingProject', params });
}

export const getProjectApi = params => {
  return apiHttp.post({ url:'/corp/project', params });
}

export const getCompanyCorpPrjApi = params => {  //企业历史业绩补录
  return apiHttp.post({ url: '/corp/corpPrj', params });
}

export const getPersonPunishApi = params => {  // 行政处罚
  return apiHttp.post({ url: '/corp/personPunish', params });
}

export const getPersonPunishApi2 = params => {  //撤销行政许可
  return apiHttp.post({ url: '/corp/rollbackPermit', params });
}

export const getCorpCreditScoreApi = params => {  //企业信用评价
  return apiHttp.post({ url: '/corp/corpCreditScore', params });
}

export const getCreditRecordGoodApi = params => {  //企业信用行为(良好)
  return apiHttp.post({ url: '/corp/creditRecordGood', params });
}

export const getCreditRecordBadApi = params => {  //企业信用行为(良好)
  return apiHttp.post({ url: '/corp/creditRecordBad', params });
}
